package com.ihd.ihardware.view.tzc.discovery.viewmodel;

import android.app.Application;
import android.arch.lifecycle.AndroidViewModel;
import android.support.annotation.NonNull;

import com.ihd.ihardware.view.tzc.discovery.model.DiscoveryRepository;

import java.io.File;

public class DTViewModel extends AndroidViewModel {

    private DiscoveryRepository mDiscoveryRepository;

    public DTViewModel(@NonNull Application application) {
        super(application);
    }

    public void updateHead(File f) {
        if (mDiscoveryRepository == null)
            mDiscoveryRepository = new DiscoveryRepository();
        mDiscoveryRepository.updateHead(f);
    }

    public void sign(String fileId, String textShow) {
        if (mDiscoveryRepository == null)
            mDiscoveryRepository = new DiscoveryRepository();
        mDiscoveryRepository.sign(fileId, textShow);
    }

    @Override
    protected void onCleared() {
        super.onCleared();
        if (null != mDiscoveryRepository) {
            mDiscoveryRepository.onDestroy();
            mDiscoveryRepository = null;
        }
    }
}
